import os
import yaml

def get_object_path():
    return os.getcwd().split('common')[0]

    # 读取extract_yml文件 access_token值的获取
def read_config_yaml(one_node,two_node):
    with open(get_object_path() + "/config.yml", mode='r', encoding='utf-8')as f:
        value = yaml.load(stream=f, Loader=yaml.FullLoader)
        return value[one_node][two_node]

def read_extract_yaml(node_name):
    with open(get_object_path() + "/extract.yml", mode='r', encoding='utf-8')as f:
        value = yaml.load(stream=f, Loader=yaml.FullLoader)
        return value[node_name]


    # 写入extract_yml文件
def write_extract_yaml(data):
    with open(get_object_path() + "/extract.yml", mode='a', encoding='utf-8')as f:
        yaml.dump(data=data, stream=f, allow_unicode=True)

    # 清空
def clear_extract_yaml():
    with open(get_object_path() + "/extract.yml", mode='w', encoding='utf-8')as f:
        f.truncate()


# def read_testcase_yaml(yaml_path):
#     with open(get_object_path() + yaml_path, mode='r', encoding='utf-8')as f:
#         value = yaml.load(stream=f, Loader=yaml.FullLoader)
#         return value;



if __name__ == '__main__':
    print(get_object_path())
#     print(read_config_yaml('base','base_gzh_url'))
#     print(read_config_yaml('base', 'base_wyn_url'))
#     print(read_config_yaml('base', 'base_php_url'))



